package ext.tianma.bom.filter;

import org.apache.log4j.Logger;
import wt.fc.WTReference;
import wt.folder.Cabinet;
import wt.folder.SubFolder;
import wt.inf.library.WTLibrary;
import wt.log4j.LogR;
import com.ptc.core.ui.validation.DefaultSimpleValidationFilter;
import com.ptc.core.ui.validation.UIValidationCriteria;
import com.ptc.core.ui.validation.UIValidationKey;
import com.ptc.core.ui.validation.UIValidationStatus;

public class ECOQueryFilter extends DefaultSimpleValidationFilter{
	//private static final Object lay = null;
	private  Logger logger = LogR.getLogger(ECOQueryFilter.class.getName());
	public UIValidationStatus preValidateAction(UIValidationKey key,
	            UIValidationCriteria criteria) {
		UIValidationStatus status = UIValidationStatus.HIDDEN;
		WTReference contextObj = criteria.getContextObject();
		Object obj = contextObj.getObject();
		String contName = "";
		String name = "";
		String des = "";
		//log.info("000000000000000"+contName);
		if (obj instanceof Cabinet){
			contName = ((Cabinet)obj).getContainerName();
		}else if (obj instanceof SubFolder){
			contName = ((SubFolder)obj).getContainerName();
		}else if(obj instanceof WTLibrary){
			contName = ((WTLibrary)obj).getContainerName();
			name = ((WTLibrary) obj).getName();
			des = ((WTLibrary) obj).getDescription();
		}
		if (("QueryECOData").equals(key.getComponentID())){
			if ("物料库".equals(name)){
					status = UIValidationStatus.ENABLED;
			}
		}
		
		return status;
	}
}
